﻿#region Copyright (c) 2008 plexBB Team

/*  Copyright (c) 2008 plexBB Team
 *  
 *  This file is free software: you may copy, redistribute and/or modify it  
 *  under the terms of the GNU General Public License as published by the  
 *  Free Software Foundation, either version 2 of the License, or (at your  
 *  option) any later version.  
 *  
 *  This file is distributed in the hope that it will be useful, but  
 *  WITHOUT ANY WARRANTY; without even the implied warranty of  
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  
 *  General Public License for more details.  
 *  
 *  You should have received a copy of the GNU General Public License  
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */

#endregion

using System.Configuration;

namespace PlexBB
{
    public class PlexBBConfigurationSection : ConfigurationSection
    {
        [ConfigurationProperty("connectionString")]
        public string ConnectionString
        {
            get
            {
                //#if PLEXBB_PRECOMPILED && DEBUG
                //                return HttpContext.Current.Server.MapPath("~/App_Data/PlexBB_Database28.mdf");
                //#else
                return (string)this["connectionString"];
                //#endif
            }
            set { this["connectionString"] = value; }
        }

        [ConfigurationProperty("urlParamPrefix")]
        [RegexStringValidator(@"^[a-zA-Z0-9\.\-_\$]*$")]
        public string UrlParamPrefix
        {
            get { return (string)this["urlParamPrefix"]; }
            set { this["urlParamPrefix"] = value; }
        }

        [ConfigurationProperty("databaseTablePrefix", DefaultValue = "plexbb_")]
        [RegexStringValidator(@"^([a-zA-Z_]+[a-zA-Z0-9_]*)?$")]
        public string DatabaseTablePrefix
        {
            get { return (string)this["databaseTablePrefix"]; }
            set { this["databaseTablePrefix"] = value; }
        }

        [ConfigurationProperty("baseDir", DefaultValue = "~/")]
        public string BaseDir
        {
            get { return (string)this["baseDir"]; }
            set { this["baseDir"] = value; }
        }

        [ConfigurationProperty("forumUrl")]
        public string ForumUrl
        {
            get { return (string)this["forumUrl"]; }
            set { this["forumUrl"] = value; }
        }

        [ConfigurationProperty("enableUrlRewriting", DefaultValue = false)]
        public bool EnableUrlRewriting
        {
            get { return this["enableUrlRewriting"] == null ? false : (bool)this["enableUrlRewriting"]; }
            set { this["enableUrlRewriting"] = value; }
        }
    }
}